package photogcalc.calc;

/** Class contains flash specific calculations.
@author Antti Okkonen
@version 2008-06-09

<pre>
Guide Number=GN
Aperture=A  (F-number)
Distance=S

GN = S * A  (at ISO 100/21)
</pre>
*/
public class ManualFlash {

    /** Default constructor. Sets guide number to 0. */
    public ManualFlash() {
    }

    /** Calculate needed guide number.
    @param sensitivity ASA part of the ISO sensitivity number.
    @param distance Distance to subject in meters.
    @param aperture Lenses aperture number (F-number).
     */
    public int calculateGuideNumber(int sensitivity, double distance, double aperture) {
        double gn = (distance * aperture) / Math.sqrt((double)sensitivity / 100.0);

        /* Rounds up if number is more than 0.1 over interger.
        1.1 becomes 2, but 1.05 is 1. */
        return (int) (0.9 * gn);
    }

    /** Calculate needed guide number using default sensitivity (ISO 100/21).
    @param distance Distance to subject in meters.
    @param aperture Lenses aperture number (F-number).
     */
    public int calculateGuideNumber(double distance, double aperture) {
        double gn = distance * aperture;

        /* Rounds up if number is more than 0.1 over interger.
        1.1 becomes 2, but 1.05 is 1. */
        return (int) (0.9 * gn);
    }
}